Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing description error #32

Merged
merged 2 commits into from
Jul 23, 2018
Merged

Fix missing description error #32

merged 2 commits into from
Jul 23, 2018

Conversation

jbmeerkat
Copy link
Contributor

When test written without description and RSpec output formatter is
"doc" rspec-expectations tries to generate output message from
matcher's description which BroadcastMatcher doesn't have.

Problem can be reproduced by simple script

# test.rb

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'

  gem 'rspec'
  gem 'wisper'
  gem 'wisper-rspec'
end

require 'wisper/rspec/matchers'

RSpec.configure do |config|
  config.default_formatter = 'doc'
end

RSpec.describe 'missing matcher description' do
  include Wisper::RSpec::BroadcastMatcher

  let(:publisher_class) { Class.new { include Wisper::Publisher } }
  let(:publisher) { publisher_class.new }

  specify do
    expect { publisher.send(:broadcast, :foo) }.to broadcast(:foo)
  end
end
$ rspec test.rb

missing matcher description
  should When you call a matcher in an example without a String, like this:

specify { expect(object).to matcher }

or this:

it { is_expected.to matcher }

RSpec expects the matcher to have a #description method. You should either
add a String to the example this matcher is being used in, or give it a
description method. Then you won't have to suffer this lengthy warning again.

Finished in 0.00497 seconds (files took 0.29444 seconds to load)
1 example, 0 failures

When test written without description and RSpec output formatter is
"doc" rspec-expectations tries to generate output message from
matcher's description which BroadcastMatcher doesn't have.
@krisleech
Copy link
Owner

Looks good, thanks for this. Could you add an item to the unreleased section of the CHANGELOG and I will merge.

@jbmeerkat
Copy link
Contributor Author

@krisleech done!

@krisleech krisleech merged commit 61f3576 into krisleech:master Jul 23, 2018
@jbmeerkat jbmeerkat deleted the feature/example-description branch July 23, 2018 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants